package com.mms.enumerate;

public enum ReserveDiagnoseType {
    hospital(1, "住院"),
    noHospital(0, "不住院");

    private int key;
    private String value;

    ReserveDiagnoseType(int key, String value) {
        this.key = key;
        this.value = value;
    }

    public static String getValueByKey(int key) {
        ReserveDiagnoseType[] values = ReserveDiagnoseType.values();
        for (ReserveDiagnoseType reserveDiagnoseType : values) {
            if (reserveDiagnoseType.key == key) {
                return reserveDiagnoseType.value;
            }
        }
        return "";
    }

    /**
     * 判断是否包含key
     *
     * @param key
     * @return
     */
    public static boolean exists(Object key) {
        try {
            return exists(Integer.parseInt(String.valueOf(key)));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 判断是否存在 特定 key
     *
     * @param key
     * @return
     */
    public static boolean exists(String key) {
        try {
            return exists(Integer.parseInt(key));
        } catch (Exception e) {
        }
        return false;
    }

    /**
     * 判断是否包含 key
     *
     * @param key
     * @return
     */
    public static boolean exists(int key) {
        ReserveDiagnoseType[] values = ReserveDiagnoseType.values();
        for (ReserveDiagnoseType reserveDiagnoseType : values) {
            if (reserveDiagnoseType.key == key) {
                return true;
            }
        }
        return false;
    }

    public int getKey() {
        return key;
    }

    public void setKey(int key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
